<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    protected string $tableName = 'admins';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->tableName)) {
            return;
        }
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->comment('管理员表');
            $table->increments('id')->comment('主键ID');
            $table->integer('created_id')->default(0)->comment('');
            $table->integer('created_at')->default(0)->comment('');
            $table->integer('updated_id')->default(0)->comment('');
            $table->integer('updated_at')->default(0)->comment('');
            $table->integer('deleted_id')->default(0)->nullable()->comment('');
            $table->integer('deleted_at')->default(0)->nullable()->comment('');
            $table->string('name', 60)->default('')->comment('用户名');
            $table->string('nickname', 60)->default('')->nullable()->comment('用户昵称');
            $table->string('password', 64)->default('')->comment('登录密码');
            $table->string('email', 60)->default('')->nullable()->comment('邮箱');
            $table->string('phone', 11)->default('')->nullable()->comment('手机号');
            $table->string('avatar', 200)->default('')->nullable()->comment('头像');
            $table->tinyInteger('sex')->default(0)->nullable()->comment('性别 0-保密 1-男 2-女');
            $table->tinyInteger('type')->default(1)->nullable()->comment('类型 0-超级管理员 1-其他');
            $table->string('lang', 10)->default('')->nullable()->comment('');
            $table->string('remark', 255)->default('')->nullable()->comment('');
            $table->integer('sorting')->default(0)->nullable()->comment('');
            $table->integer('auto_logout')->default(0)->nullable()->comment('');
            $table->integer('last_login_time')->default(0)->nullable()->comment('最后登录时间');
            $table->string('last_login_ip', 16)->default('')->nullable()->comment('最后登录ip');
            $table->string('token', 255)->default('')->nullable()->comment('身份令牌');
            $table->integer('token_expire')->default(0)->nullable()->comment('令牌有效期');
            $table->tinyInteger('status')->default(0)->comment('状态 0-未验证 1-正常 2-禁用');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
};
